<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">

    <link href="jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet"/>
    <link href="jquery/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css" type="text/css"
          rel="stylesheet"/>


    <script type="text/javascript" src="jquery/jquery-1.11.1-min.js"></script>
    <script type="text/javascript" src="jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
</head>
<script>
    $(function () {
        // 给保存添加单击事件验证字典编码和字典值是否为空
        $("#saveCreateDicValueBtn").on("click", function () {
            var createDicTypeCode = $("#create-dicTypeCode").val();
            if (!createDicTypeCode) {
                alert("请选择字典类型编码！");
                return;
            }
            var createDicValue = $("#create-dicValue").val();
            if (!createDicValue) {
                alert("字典值不能为空！");
                return;
            }
            var createText = $("#create-text").val();
            var createOrderNo = $("#create-orderNo").val();
            $.ajax({
                url: "settings/dictionary/type/saveCreateDicValue.do",
                type: "post",
                data: {
                    typeCode:createDicTypeCode,
                    value:createDicValue,
                    text:createText,
                    orderNo:createOrderNo,
                },
                success: function (data) {
                    if (data.code === 1000) {
                        alert("添加成功！");
                        window.location.href = "settings/dictionary/value/index.do";
                    } else {
						alert(data.message);
                    }
                }
            })
        })
    })
</script>
<body>

<div style="position:  relative; left: 30px;">
    <h3>新增字典值</h3>
    <div style="position: relative; top: -40px; left: 70%;">
        <button id="saveCreateDicValueBtn" type="button" class="btn btn-primary">保存</button>
        <button type="button" class="btn btn-default" onclick="window.history.back();">取消</button>
    </div>
    <hr style="position: relative; top: -40px;">
</div>
<form class="form-horizontal" role="form">

    <div class="form-group">
        <label for="create-dicTypeCode" class="col-sm-2 control-label">字典类型编码<span style="font-size: 15px; color: red;">*</span></label>
        <div class="col-sm-10" style="width: 300px;">
            <select class="form-control" id="create-dicTypeCode" style="width: 200%;">
                <option value="">-----------请选择-----------</option>
                <c:forEach items="${dicTypes}" var="dicType">
                    <option value="${dicType.code}">${dicType.name}</option>
                </c:forEach>

            </select>
        </div>
    </div>

    <div class="form-group">
        <label for="create-dicValue" class="col-sm-2 control-label">字典值<span
                style="font-size: 15px; color: red;">*</span></label>
        <div class="col-sm-10" style="width: 300px;">
            <input type="text" class="form-control" id="create-dicValue" style="width: 200%;">
        </div>
    </div>

    <div class="form-group">
        <label for="create-text" class="col-sm-2 control-label">文本</label>
        <div class="col-sm-10" style="width: 300px;">
            <input type="text" class="form-control" id="create-text" style="width: 200%;">
        </div>
    </div>

    <div class="form-group">
        <label for="create-orderNo" class="col-sm-2 control-label">排序号</label>
        <div class="col-sm-10" style="width: 300px;">
            <input type="text" class="form-control" id="create-orderNo" style="width: 200%;">
        </div>
    </div>
</form>

<div style="height: 200px;"></div>
</body>
</html>
